package com.luyou.awt.image;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;

/**
 * 生成略缩图
 */
public class ZoomImage {

    /**
     * 缩小后图片的大小
     */
    private final int WIDTH = 60;
    private final int HEIGHT = 60;

    BufferedImage image = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB);
    Graphics g = image.getGraphics();

    public void zoom() throws Exception{
        //读取原始位图
        Image srcImage = ImageIO.read(new File("微信图片.jpg"));
        g.drawImage(srcImage, 0, 0,WIDTH, HEIGHT, null);
        ImageIO.write(image, "jpg", new File("微信图片_60_60.jpg"));
    }

    public static void main(String[] args) throws Exception {
        new ZoomImage().zoom();
    }
}
